package com.appheader.rongmaphone.db;


import android.database.sqlite.SQLiteDatabase;

import com.appheader.rongmaphone.cache.db.AbsDBManager;
import com.appheader.rongmaphone.constants.GlobalVars;
/**
 * Created by lpc on 16/6/15.
 *
 */
public class DBManager extends AbsDBManager {
    //TODO:need to complete
    private static DBManager mDBManager;
    //Dao
    public static DBManager getDBManager(){
        if (mDBManager == null)
            mDBManager = new DBManager();
        return mDBManager;
    }
    //getDao
    public static SQLiteDatabase getDB(){
        if (dbHelper == null){
            dbHelper = new DatabaseHelper(GlobalVars.getContext());
        }
        if (database == null){
            database = dbHelper.getWritableDatabase();
        }
        return database;
    }
    @Override
    public void createDBTable(String userIdentifier) {
        //方案表
        getDB().execSQL("CREATE TABLE IF NOT EXISTS "+DBConst.TABLE_CLOUD+DBConst.TABLE_LINK+userIdentifier+"(" +
                DBConst.CloudId+" TEXT(50,0) NOT NULL PRIMARY KEY," +
                DBConst.CloudName+" TEXT(50,0)," +
                DBConst.PicId+" TEXT(500,0),"+
                DBConst.LastModifyTime+" TEXT(50,0)" +")");
    }
}
